import request from '@/utils/request'
import {Message } from 'element-ui'
import { error } from 'util'
// 获取用户组list
export function getUserGroup(data, succCb) {
  return request({
    url: 'groups/',
    method: 'get',
    params: data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('getUserGroup-->>')
  })
}

// 获取用户组Select
export function getUserGroupSelect(succCb) {
  return request({
    url: 'groups/selectable',
    method: 'get'
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('getUserGroupSelect-->>')
  })
}

// 添加用户组
export function addUserGroup(data, succCb) {
  return request({
    url: 'groups/',
    method: 'post',
    data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('addUserGroup-->>')
  })
}

// 删除用户组
export function delUserGroup(id, succCb) {
  return request({
    url: 'groups/' + id,
    method: 'delete'
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('delUserGroup-->>')
  })
}

// 用户组详情
export function UserGroupDetail(id, succCb) {
  return request({
    url: 'groups/' + id,
    method: 'get'
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('UserGroupDetail-->>')
  })
}

// 更新用户组
export function updateUserGroup(id, data, succCb) {
  return request({
    url: 'groups/' + id,
    method: 'put',
    data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('updateUserGroup-->>')
  })
}

